<template>
  <div class="bookTop">
    <div @click="handleReturn">
      <i class="i-carbon:arrow-left"></i>
      {{ title }}
    </div>
    <div>
      <slot> </slot>
    </div>
  </div>
</template>

<script setup lang="ts">
import { toRefs, defineProps } from "vue";
const props = defineProps({
  title: {
    type: String,
    default: "书籍列表",
  },
  pageUrl: {
    type: String,
    default: "",
  },
});
const { title, pageUrl } = toRefs(props);
const handleReturn = () => {
  if (pageUrl.value) {
    uni.reLaunch({
      url: pageUrl.value,
    });
  } else {
    uni.navigateBack();
  }
};
</script>

<style lang="scss" scoped>
.bookTop {
  display: flex;
  height: 100rpx;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  padding: 0 20rpx;
  color: #000;
}
</style>
